﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CSP.Dao.CommonDao;
using CSP.Dao.IObjectDaos.CSP;
using CSP.DataAccess;
using CSP.Model.CSP;
using System.Collections.ObjectModel;

namespace CSP.Dao.ObjectDaos.CSP
{
    public class RateStatisticDao : CSPCommonDao, IRateStatisticDao
    {
        public RateStatisticDao(CSPContext context, bool isTransaction = false)
            : base(context, isTransaction)
        {

        }

        public ICollection<RateStatistic> GetRateStatisticsByUser(string userName)
        {
            ICollection<RateStatistic> result = new Collection<RateStatistic>();
            var rateStatistics = _context.RateStatistics.Where(r => r.ToUserName == userName);
            if (rateStatistics.Count() != 0)
            {
                result = rateStatistics.ToArray();
            }
            return result;
        }
    }
}
